package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.DeleteMsgRequest;
import keeto.com.vn.bms.network.response.DeleteMsgResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskDeleteMsg extends AbstractTask{

	private String ID;
	private String authKey;
	
	
	public TaskDeleteMsg(BMSListener listener, IBMSCore core, String iD,
			String authKey) {
		super(listener, core);
		this.ID = iD;
		this.authKey = authKey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		DeleteMsgRequest request = new DeleteMsgRequest();
		request.setId(ID);
		request.setAuthKey(authKey);
		DeleteMsgResponse response = protocol.DeleteMsg(request);
		for (BMSListener mlistener : listener){
			mlistener.finishDeleteMsg(response.getReturnCode(), response.getResuiltMsg());
		}
	}
	
	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for (BMSListener mlistener : listener){
			mlistener.finishDeleteMsg(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, null);
		}
	}
	
	

	
}
